package com.stone.ai.robot.config;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.deepseek.DeepSeekChatModel;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Configurable
@Component
public class ChatClientConfig {

    @Resource
    private ChatMemory chatMemory;

    @Bean
    public ChatClient chatClient(DeepSeekChatModel deepSeekChatModel){
        return ChatClient
                .builder(deepSeekChatModel)
                .defaultSystem("请你扮演中国邮政客服的角色 ")
                .defaultAdvisors(new SimpleLoggerAdvisor() //添加Spring AI 内置的日志记录功能
                        , MessageChatMemoryAdvisor.builder(chatMemory).build() //开启对话记录功能

                )
                .build();
    }
}
